package com.situ.mall.controller.front;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.situ.mall.entity.Category;
import com.situ.mall.service.ICategoryService;

@Controller
public class FrontIndexController {
	
	@Autowired
	private ICategoryService categoryService;

// 0.获取 category一二级分类转发到 index。jsp
	@RequestMapping("/index.shtml")
	public String index(Model model) {
		System.out.println("FrontIndexController.index()");
		
		//获取一级分类
		List<Category> topCategoryList = categoryService.getTopCategoryList();
		
		//获取二级分类
		List<Category> secondCategoryList = categoryService.getSecondCategoryList();
		
		System.out.println("topCategoryList"+topCategoryList);
		System.out.println("secondCategoryList"+secondCategoryList);
		
		
		model.addAttribute("topCategoryList",topCategoryList );
		model.addAttribute("secondCategoryList",secondCategoryList );
		
		
		return "/index";
	}

}
